package com.naiterui.ehp.bs.b2c.product.repository;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bs.b2c.product.entity.Product;
import com.naiterui.ehp.bs.b2c.product.entity.Sku;

/**
 * 商品主记录
 *
 * @author zhoupeipei
 * @date 2019-05-17 16:12
 * @since 1.0.0
 */
@Repository
public interface IProductRepository extends BaseJpaRepository<Product, Long> {
    /**
     * 根据id  批量获取商品
     *
     * @param pids
     *
     * @return
     */
    List<Product> findAllByIdIn(Set<Long> pids);

    /**
     * 获取商品名称
     * @param name 搜索关键字
     * @return list
     */
    @Query(nativeQuery = true, value = "select name from p_product where name like  CONCAT('%',:name,'%') limit 10")
    List<String> findByNameLike(@Param("name") String name);

    List<Product> findAllByIdIn(Collection<Long> productIds);
}
